#!/bin/bash
#########################################################
#							#
# This are NScripts v3.5				#
#							#
# Licensed under the GNU GENERAL PUBLIC LICENSE 3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

action=$(zenity --list --radiolist --width 430 --height 270 --title "Apt Cache" --text "Choose an Action to perform" --column Pick --column Action TRUE "showpkg (show information for a package)" FALSE "showsrc (show information for a source-package)" FALSE "search (search in the database via regular expressions)" FALSE "show (show information for a package)" FALSE "depends (show dependencies of a package)" FALSE "rdepends (show reverse dependencies of a package)" FALSE "pkgnames (list names of all installed packages)")

#package=$(zenity --entry --title Package --text "Choose a package")
#zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt

if [[ $action == shwopkg* ]]; then
	package=$(zenity --entry --title Package --text "Choose a package")
	apt-cache showpkg $package > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == showsrc* ]]; then
	package=$(zenity --entry --title Package --text "Choose a package")
	apt-cache showsrc $package > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == search* ]]; then
	term=$(zenity --entry --title Package --text "Enter search-term")
	apt-cache search $term > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == show* ]]; then
	package=$(zenity --entry --title Package --text "Choose a package")
	apt-cache show $package > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == depends* ]]; then
	package=$(zenity --entry --title Package --text "Choose a package")
	apt-cache depends $package > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == rdepends* ]]; then
	package=$(zenity --entry --title Package --text "Choose a package")
	apt-cache rdepends $package > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
elif [[ $action == pkgnames* ]]; then
	apt-cache pkgnames > /tmp/apt_cache.txt
	zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/apt_cache.txt
fi
